package com.eleven.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eleven.pojo.Funding;
import com.eleven.pojo.Msg;
import com.eleven.service.FundingService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
public class FundingController {

	@Autowired
	FundingService fundingService;

	public FundingService getFundingService() {
		return fundingService;
	}

	public void setFundingService(FundingService fundingService) {
		this.fundingService = fundingService;
	}
	
	/**
	 * 根据项目id查找参与表及相关表的信息
	 * 
	 * @param pn
	 * @param fdPsId
	 * @return
	 */
	@RequestMapping(value="/getFundingByfdPsId",method=RequestMethod.GET)
	@ResponseBody
	public Msg getFundingByfdPsId(@RequestParam(value="pn",defaultValue="1")Integer pn,@RequestParam("fdPsId") Integer fdPsId) {
		PageHelper.startPage(pn, 8);//传入页码和每页显示的数量
		List<Funding> fundingsList = fundingService.getFundingByfdPsId(fdPsId);
		//把数据封装到PageInfo中
		//参数1：要显示的数据
		//参数2：连续查询n页的内容
		PageInfo pageInfo = new PageInfo(fundingsList, 5);//5是连续显示5页的内容
		if(fundingsList.size() > 0) {
			return Msg.success().add("pageInfo", pageInfo);
		}else {
			return Msg.fail();
		}
		
	}
	
	
	
}
